package com.wash.shoes.controller.mobile;

import com.ruoyi.common.core.domain.R;
import com.wash.shoes.controller.pc.BaseController;
import com.wash.shoes.entity.ShopGoodsPo;
import com.wash.shoes.service.ShopGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhengyunpeng
 * @since 2024-08-26
 */
@Api(tags = {"移动端-商品"})
@RestController
@Log4j2
@RequestMapping("/mobile-api/shopGoods")
public class ShopGoodsMController extends BaseController {

    @Autowired
    ShopGoodsService shopGoodsService;

    @ApiOperation("获取商品列表")
    @PostMapping("/typeGoodsList")
    public R<List<ShopGoodsPo>> typeGoodsList(String typeId, @RequestParam(required = false) Integer sellType) {
        // 如果没有配置就是小程序的
        if (sellType == null) {
            sellType = 2;
        }
        List<ShopGoodsPo> dataList = shopGoodsService.typeGoodsList(typeId, sellType);
        return R.ok(dataList);
    }

    @ApiOperation("获取详情")
    @PostMapping("/getDetailById")
    public R<ShopGoodsPo> getDetailById(String theId) {
        ShopGoodsPo shopGoodsPo = shopGoodsService.getById(theId);
        return R.ok(shopGoodsPo);
    }

}

